﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogisticsBLL;
using Model;
using System.Web.UI.HtmlControls;

namespace WebLosgic.TruckTeam
{
    public partial class TeamXtruck : System.Web.UI.Page
    {

        public static Trucks ts;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindRpt();
                //DropBind();
            }
        }

        //public void DropBind()
        //{
        //    TruckBLL tbl = new TruckBLL();
        //    DdlTruck.DataSource = tbl.ddlbindCarName();
        //    DdlTruck.DataTextField = "TeamName";
        //    DdlTruck.DataValueField = "TeamID";
        //    DdlTruck.DataBind();
        //    DdlTruck.Items.Insert(0, new ListItem("-请选择-", "0"));
        //}


        public void BindRpt()
        {
            TruckBLL tb = new TruckBLL();
            RptTeam.DataSource = tb.read();
            RptTeam.DataBind();

        }


        protected void RptTeam_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
          
            if(e.Item.ItemType==ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {

                
                Repeater pea = (Repeater)e.Item.FindControl("RptTruck");
                Trucks trk = (Trucks)e.Item.DataItem;
                int Teamid = trk.TeamID;
                TruckBLL tb = new TruckBLL();
                pea.DataSource = tb.readNumber(Teamid);
                pea.DataBind();

            }
        }

        protected void BtnUpdate_Click(object sender, EventArgs e)
        {
            Response.Redirect("UpdateTruck.aspx");
        }



        protected string getcut(string str)
        {
            int len = 10;
            if (str.Length > len)
            {
                return str.ToString().Substring(0, len) + "...";
            }
            else
            {
                return str;
            }
        }

        //protected void Btncha_Click(object sender, EventArgs e)
        //{
        //    //TruckBLL tb = new TruckBLL();
        //    //int TeamID = Convert.ToInt32(DdlTruck.SelectedValue);
        //    //RptTeam.DataSource = tb.readTruckSel(TeamID);
        //    //RptTeam.DataBind();
        //}
    }
}